//
//  YLInvestmentTableViewCell.m
//  YLFinanceService
//
//  Created by she1323 on 2017/9/12.
//  Copyright © 2017年 she1323. All rights reserved.
//  投资券

#import "YLInvestmentTableViewCell.h"
#import "YLInvestmentCertificateModel.h"
#import "YLGlobeHeader.h"
@interface YLInvestmentTableViewCell ()
// 可用额度
@property (weak, nonatomic) IBOutlet UILabel *availableAmountLabel;
// 平台限制
@property (weak, nonatomic) IBOutlet UILabel *platformExplainLabel;
// 投资额限制
@property (weak, nonatomic) IBOutlet UILabel *investmentExplainLabel;
// 产品限制
@property (weak, nonatomic) IBOutlet UILabel *useringExplainLabel;
// 时间
@property (weak, nonatomic) IBOutlet UILabel *timeLabel;
@property (weak, nonatomic) IBOutlet UIImageView *icon;
// 标识
@property (weak, nonatomic) IBOutlet UILabel *sendReasonLabel;
// 加息底部
@property (weak, nonatomic) IBOutlet UIView *increaseInterestBaseView;
// 加息
@property (weak, nonatomic) IBOutlet UILabel *increaseInterestLabel;
// 立即使用
@property (weak, nonatomic) IBOutlet UILabel *useNowLabel;
@property (nonatomic, strong) IBOutletCollection(UILabel) NSArray *labels;
@end


@implementation YLInvestmentTableViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
}

- (void)setModel:(YLInvestmentCertificateModel *)model
{
    _model = model;
    
    _platformExplainLabel.text = model.platformExplain;
    _investmentExplainLabel.text = model.investmentExplain;
    _useringExplainLabel.text = model.useringExplain;
    _timeLabel.text = [NSString stringWithFormat:@"%@至%@", model.effectiveDate, model.expirationDate];
    _sendReasonLabel.text = model.sendReason;
    
    // 满减券
    if (model.voucherType == 2) {
        _increaseInterestBaseView.alpha = 0;
        _availableAmountLabel.hidden = NO;
        _availableAmountLabel.text = [NSString stringWithFormat:@"%@元", model.discountQuota];
    } else {
        // 加息券
        _increaseInterestBaseView.alpha = 1;
        _availableAmountLabel.hidden = YES;
        _increaseInterestLabel.text = [NSString stringWithFormat:@"%@%%", model.discountQuota];
    }
    
    // 可使用 已领取
    if (model.voucher2CustomerState == 20) {
        for (UILabel *label in self.labels) {
            label.textColor = YLLOrgColor;
        }
        _timeLabel.textColor = [UIColor blackColor];
        _useNowLabel.backgroundColor = YLLOrgColor;
        _platformExplainLabel.textColor = YLLOrgColor;
        _sendReasonLabel.textColor = YLLOrgColor;
        _icon.image = [UIImage imageNamed:@"WelfareTag"];
    } else {
        for (UILabel *label in self.labels) {
            label.textColor = [UIColor lightGrayColor];
        }
        _useNowLabel.backgroundColor = [UIColor lightGrayColor];
        _platformExplainLabel.textColor = [UIColor lightGrayColor];
        _timeLabel.textColor = [UIColor lightGrayColor];
        _sendReasonLabel.textColor = [UIColor lightGrayColor];
        _icon.image = [UIImage imageNamed:@"WelfareTagGary"];
        
        if (model.voucher2CustomerState == -20) {
            _useNowLabel.text = @"已 使 用";
        }
        
        if (model.voucher2CustomerState == 3) {
            _useNowLabel.text = @"已 过 期";
        }
        
        
    }
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];
}

+ (NSString *)cellID
{
    return @"YLInvestmentTableViewCell";
}

@end
